package com.cxyd.modules.wcs.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.cxyd.common.service.impl.CrudServiceImpl;
import com.cxyd.modules.wcs.dao.RouteCtuDao;
import com.cxyd.modules.wcs.dao.UrlMappingDao;
import com.cxyd.modules.wcs.dto.RouteCtuDTO;
import com.cxyd.modules.wcs.dto.UrlMappingDTO;
import com.cxyd.modules.wcs.entity.RouteCtuEntity;
import com.cxyd.modules.wcs.entity.UrlMappingEntity;
import com.cxyd.modules.wcs.service.RouteCtuService;
import com.cxyd.modules.wcs.service.UrlMappingService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class UrlMappingServiceImpl extends CrudServiceImpl<UrlMappingDao, UrlMappingEntity, UrlMappingDTO> implements UrlMappingService {
    @Override
    public QueryWrapper<UrlMappingEntity> getWrapper(Map<String, Object> params) {
        String urlNo = (String) params.get("url_no");
        final QueryWrapper<UrlMappingEntity> wrapper = new QueryWrapper<>();
        wrapper.like(StringUtils.isNotBlank(urlNo), "url_no", urlNo);
        return wrapper;
    }

    @Override
    public UrlMappingEntity getUrlByNo(String urlNo) {
        QueryWrapper<UrlMappingEntity> qw = new QueryWrapper<>();
        qw.eq("url_no", urlNo).last("limit 1");
        return baseDao.selectOne(qw);
    }
}
